data("ny_noaa")

clean_ny = ny_noaa %>% 
  janitor::clean_names() %>% 
  mutate(
    year = lubridate::year(date),
    month = lubridate::month(date, label = TRUE),
    prcp = as.numeric(prcp) / 10, 
    tmax = as.numeric(tmax) / 10,
    tmin = as.numeric(tmin) / 10
  )%>% 
filter(
    date >= as.Date("2008-01-01") & date <= as.Date("2008-12-31"))

Column

Chart A

plot_ly(
  data = clean_ny,
  x = ~month,
  y = ~tmax,
  type = 'box',
  boxpoints = 'outliers',
  color = ~month, 
  colors = "viridis",
  marker = list(size = 4)
) %>%
  layout(
    title = "Monthly Distribution of Maximum Temperature in New York (2008)",
    xaxis = list(title = "Month"),
    yaxis = list(title = "Max Temperature (°C)")
  )
## Warning: Ignoring 71921 observations

Column

Chart B

monthly_pre = clean_ny %>% 
  filter(!is.na(prcp)) %>% 
  group_by(month) %>% 
  summarise(total_prcp = sum(prcp, na.rm = TRUE))

# Create bar plot using plotly
plot_ly(
  data = monthly_pre,
  x = ~month,
  y = ~total_prcp,
  type = 'bar',
  color = ~month,
  colors = "viridis"
) %>%
  layout(
    title = "Total Monthly Precipitation in New York (2008)",
    xaxis = list(title = "Month"),
    yaxis = list(title = "Total Precipitation (mm)"),
    showlegend = FALSE
  )

Chart C

clean_ny <- clean_ny %>%
  mutate(text_label = str_c("Min Temp: ", tmin, "°C\nMax Temp: ", tmax, "°C"))

plot_ly(
  data = clean_ny,
  x = ~tmin,
  y = ~tmax,
  type = 'scatter',
  mode = 'markers',
  color = ~month, 
  colors = "viridis",
  text = ~text_label,
  marker = list(size = 6, opacity = 0.7) 
) %>%
  layout(
    title = "Scatter Plot of Maximum Temperature vs. Minimum Temperature in New York (2008)",
    xaxis = list(title = "Min Temperature (°C)"),
    yaxis = list(title = "Max Temperature (°C)"),
    showlegend = TRUE
  )
## Warning: Ignoring 71969 observations